﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Collections.Generic;
using HZ.DrugTrade.Web;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.Model.Enum;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;

namespace HZ.DrugTrade.Web.Hospitals.Collection
{
    public partial class GoodsOfInvoicePay : BasePage
    {
        private int totalRecord;
        private IBLL_Purchase iPurchase = Factory.BLL_Purchase();

        public GoodsOfInvoicePay()
        {
            this.ModuleNo = Module.结算单管理.ToString();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //显示采购单名称
                this.lblInvoicePayName.Text = Request.QueryString["PName"];
                
                //绑定明细
                Binddata();
                
            }
        }

        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            Binddata();
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            Binddata();
        }

        /// <summary>
        /// 通过结算单号查找所有产品的入库总量
        /// </summary>
        protected void Binddata()
        {
            //Model.Query.Distribution qryCondition = new HZ.DrugTrade.Model.Query.Distribution();
            //qryCondition.OrderDetailID = new HZ.Common.ConvertHelper(Request.QueryString["OID"]).String;
            //qryCondition.SortFields = " DistributeTime desc,OrderName ASC ";

            Model.Query.ProcureCatalog where = new Model.Query.ProcureCatalog();
            where.SortFields = " ProductName  ";
            DataTable dt = iPurchase.GetPurchaseSumQueryByInvoicePay(where, new HZ.Common.ConvertHelper(Request.QueryString["PID"]).String, this.AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalRecord);
            this.gvGoods.AutoGenerateColumns = false;
            gvGoods.DataSource = dt;
            gvGoods.DataBind();
            this.AspNetPager1.RecordCount = totalRecord;
        }
    }
}
